$(function(){
	$("#searchFile i").click(function(){
		var fileName = $("#fileName").val();
		var fid = $("#fid").val();
		if(fileName == '') {
			alert("请输入文件名称");
			return false;
		}
		$.ajax({
			type:"post",
			url:"/file/detail/query",
			data:{"name":fileName,"fid":fid},
			success:function(data){
				$("#mytable").html(data);
				$('i[name="fileClass"]').each(function(){
		    		 againUploadFile($(this).attr("id"));
	    		  });
			}
		})
	})
	$('#fileName').keydown(function(e){
		if(e.keyCode==13){
			var fileName = $("#fileName").val();
			var fid = $("#fid").val();
			if(fileName == '') {
				alert("请输入文件名称");
				return false;
			}
			$.ajax({
				type:"post",
				url:"/file/detail/query",
				data:{"name":fileName,"fid":fid},
				success:function(data){
					$("#mytable").html(data);
					$('i[name="fileClass"]').each(function(){
			    		 againUploadFile($(this).attr("id"));
		    		  });
				}
			})
		}
	});
})
var $delFileID;
$('#delFileModal').on('show.bs.modal', function (data) {  
  $delFileID = data.relatedTarget.attributes.dataid.nodeValue;
})
$('#delFileOK').click(function(){
	$.ajax({
		type : "post",
		url : "/file/moveFile",
		data : {
			"id" : $delFileID
		},
		dataType : "json",
		success : function(data) {
			location.reload(); 
		}
	});
});
$('#delCheckFileOK').click(function(){
	var selectFile = '';
	$("input:checkbox[name='selectFile']:checked").each(function(){
		selectFile+=$(this).val()+",";
	})
	$.ajax({
		type : "post",
		url : "/file/moveAllFile",
		data : {
			"fileStr" : selectFile
		},
		dataType : "json",
		success : function(data) {
			if (data.status == true) {
				location.reload(); 
			}
		}
	});
});
function deleteSelectFile(){
	var selectFile = '';
	$("input:checkbox[name='selectFile']:checked").each(function(){
		selectFile+=$(this).val()+",";
	})
	if(selectFile=='') {
		alert("请选择要删除的记录");
		return false;	
	}
	$('#delCheckFile').modal('show');
}

var method;
method = function(){
	var fileName = $("#fileName").val();
	var fid = $("#fid").val();
	var pageNo = $("#pageNo").val();
	$.ajax({
		type:"post",
		url:"/file/detail/query",
		data:{"pageNo": pageNo, "name":fileName,"fid":fid},
		success:function(data){
			$("#mytable").html(data);
		}
	});
}